﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using AnalyseCrmMana;

namespace AnalyseCRM.InteractiveData
{
    public partial class TradingChannelsAnalyseAjax : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["parValueID"] != null)
            {
                string pavalue = Request.Params["parValueID"].ToString();
                string pType = Request.Params["parType"].ToString();
                //StringBuilder strReturn = buildHtml(pavalue, pType, "");
                //Response.Write(strReturn.ToString());
            }
        }

        [System.Web.Services.WebMethod]
        public static StringBuilder buildHtmlTest(string parValueID)
        {
            StringBuilder returnValue = new StringBuilder();
            return returnValue;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="prparamValue"></param>
        /// <param name="prparamType"></param>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string buildHtml(string parValueID, string parType,string EndDate)
        {
            string strparValueID = parValueID;
            StringBuilder returnValue = new StringBuilder();

            ChartBuildMana chartbm1 = new ChartBuildMana().getChartBuildOther(parValueID, parType, EndDate);
            if (chartbm1 != null)
            {
                returnValue.Append(JsonHelper.ObjectToJson(chartbm1));
            }
            else
            {
                returnValue.Append("NONE");
            }
            return returnValue.ToString();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="prparamValue"></param>
        /// <param name="prparamType"></param>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string buildHtml2(string parValueID, string EndDate, string strWhere)
        {
            string strparValueID = parValueID;
            StringBuilder returnValue = new StringBuilder();

            ChartBuildMana chartbm1 = new ChartBuildMana().getChartBuildOther2(parValueID,EndDate,strWhere);
            if (chartbm1 != null)
            {
                returnValue.Append(JsonHelper.ObjectToJson(chartbm1));
            }
            else
            {
                returnValue.Append("NONE");
            }
            return returnValue.ToString();
        }

        /// <summary>
        /// 所有数据查询
        /// </summary>
        /// <param name="prparamValue"></param>
        /// <param name="prparamType"></param>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string GetGridDataAll(string strEndDate, string strWhere)
        {
            StringBuilder returnValue = new StringBuilder();
            TradingChannelsMana mana = new TradingChannelsMana();
            IList<TradingChannelsMana> lstChannel = mana.GetTradingChannelsConditionAll(strEndDate, strWhere);
            //ChartBuildMana chartbm1 = new ChartBuildMana().getChartBuildOther2(parValueID, strWhere);
            int retCount = mana.GetTradingChannelsConditionCount(strEndDate, strWhere);
            if (lstChannel != null)
            {
                returnValue.Append(JsonHelper.ListToJson(lstChannel));
            }
            else
            {
                returnValue.Append("NONE");
            }
            return returnValue.ToString();
        }


        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prparamValue"></param>
        /// <param name="prparamType"></param>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string GetGridData(string strEndDate, string strWhere, string FromPage)
        {
            StringBuilder returnValue = new StringBuilder();
            TradingChannelsMana mana = new TradingChannelsMana();
            IList<TradingChannelsMana> lstChannel = mana.GetTradingChannelsCondition(strEndDate,strWhere,int.Parse(FromPage));
            //ChartBuildMana chartbm1 = new ChartBuildMana().getChartBuildOther2(parValueID, strWhere);
            int retCount = mana.GetTradingChannelsConditionCount(strEndDate, strWhere);
            if (lstChannel != null)
            {
                returnValue.Append(JsonHelper.ListToJson(lstChannel));
                returnValue.Append("$" + retCount.ToString());
            }
            else
            {
                returnValue.Append("NONE");
            }
            return returnValue.ToString();
        }

    }
}